import logging

import jwt

logger = logging.getLogger(__name__)

TOKEN_KEY = 'ShareShop'
ALG = 'HS256'


def jwt_decode(token):
    payload = {}
    try:
        decode_value = jwt.decode(token, TOKEN_KEY, algorithms=ALG)
        payload = {
            'member_id': decode_value['member_id'],
        }
    except Exception as e:
        logger.error(e.args)
    return payload
